# 互斥锁
from threading import Thread, Lock
import time

count = 100


def fun():
    global count
    mutex.acquire()  # 获得锁
    count -= 1
    print(count)
    mutex.release()  # 释放锁


if __name__ == "__main__":
    mutex = Lock()
    for i in range(10):
        t = Thread(target=fun)
        t.start()
    time.sleep(100)  # 防止主进程过早退出
